import requests
import app
import utils
# 登录
resp = requests.post(url=app.BASE_URL + '/api/sys/login',headers=app.HEADERS,
                     json={'mobile': '13800000002', 'password': '123456'})
print(resp.json())
# 获取令牌
token = 'Bearer ' + resp.json().get('data')
app.HEADERS['Authorization'] = token




# 添加部门

clad = {'name':'外星部','code':'001'}
respu = requests.post(url=app.BASE_URL + '/api/company/department',headers = app.HEADERS,json=clad)
print(respu.json())

# 获取添加部门id
clad_id = respu.json().get('data').get('id')

# 获取部门信息
resp = requests.get(url=app.BASE_URL + '/api/company/department/' + clad_id ,headers= app.HEADERS)

print(resp.json())

# 修改部门
coder={'name':'打怪部','code':'009'}
resp = requests.put(url=app.BASE_URL + '/api/company/department/' + clad_id,headers=app.HEADERS,json=coder)

print(resp.json())

# 删除部门

resp = requests.delete(url=app.BASE_URL + '/api/company/department/' + clad_id,headers=app.HEADERS)

print(resp.json())